package com.sky.com.sky.mapper;

import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    @Select("select * from setmeal_dish where dish_id=#{dishId}")
    List<SetmealDish> listByDishId(Long dishId);


    // 保存中间表数据
    void insert(SetmealDish setmealDish);

    @Select("select * from setmeal_dish where setmeal_id=#{setmealId}")
    List<SetmealDish> listBySetmealId(Long setmealId);


    // 根据套餐id删除套餐和菜品的关联关系
    @Delete("delete from setmeal_dish where setmeal_id = #{id}")
    void deleteBySetmealId(Long id);

    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void deleteById(Long setmealId);

    // 查询菜品是否有关联的套餐
    Integer countByDishIds(List<Long> ids);


    // 根据套餐id查询
    @Select("select * from setmeal_dish where setmeal_id=#{setmealId}")
    List<SetmealDish> getListBySetmealId(Long setmealId);

}
